//
//  JYUser.swift
//  01.weibo
//
//  Created by 谢玉锋 on 16/7/16.
//  Copyright © 2016年 itheima.cn. All rights reserved.
//

import UIKit

class JYUser: NSObject {
    /// 用户UID
    var id: Int64 = 0
    
    /// 用户昵称
    var screen_name: String?
    
    /// 用户头像地址（中图,50×50像素
    var profile_image_url: String?
    
    
    //注意: 这里涉及到模型提供的属性不方便: 然后进行了稍微的改造
    
    
    /// verified_type 没有认证:-1   认证用户:0  企业认证:2,3,5  达人:220
    var verified_type: Int = -1 {
        didSet {
            
                switch verified_type {
                case 0:
                    verified_typeImage = UIImage(named: "avatar_vip")
                case 2,3,5:
                    verified_typeImage = UIImage(named: "avatar_enterprise_vip")
                case 220:
                    verified_typeImage = UIImage(named: "avatar_grassroot")
                default:
                    verified_typeImage = nil
                }
        }
    }
     //注意: 这里涉及到模型提供的属性不方便: 然后进行了稍微的改造    !!!
    var verified_typeImage: UIImage?
    
    
    /// 会员等级: 1-6级
    var mbrank: Int = 0 {
        didSet {
            if mbrank > 0 && 6 >= mbrank {
                menberViewImage = UIImage(named:"common_icon_membership_level\(mbrank)")
            }else {
                menberViewImage = nil
            }
        }
    }
     //注意: 这里涉及到模型提供的属性不方便: 然后进行了稍微的改造         !!!
    var menberViewImage: UIImage?
    init(dict: [String: AnyObject]) {
        super.init()
        setValuesForKeysWithDictionary(dict)
        
    }
    // 字典中得key在模型中找不到对应的属性
    override func setValue(value: AnyObject?, forUndefinedKey key: String) { }
    
    //重写这个方法作用: 能输出模型的属性    提示: 别忘了包装 getter 方法
   override var description: String {
        get {
            let keys = ["id", "screen_name", "profile_image_url", "verified_type", "mbrank"]
            
            return "\n\t\t: 用户模型: \(self.dictionaryWithValuesForKeys(keys))"
        }
    }
}








